
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>初识setup</title>
</head>
<body>
    <div id="app"></div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
    const {ref} =Vue
    const app = Vue.createApp({
        template: `
            <div>
                <h1>我的信息</h1>
                <h2>姓名：andy</h2>
                <h2>性别：sex</h2>
                <h2>年龄：age</h2>
                <button @click="changeInfo" > 修改信息</button>
            </div>
        `,
// let name = 'andy'; 这个是普通数据，不是响应式数据：
//响应式数据：  let name =ref('andy');
       setup(props){
           let name =ref('andy');
           let age = ref(25);
           function changeInfo(){
               name.value = 'james'
               age.value = 18;
               console.log(name, age);
           }
           return {name, age, changeInfo}
       }
    })

    const vm = app.mount("#app")
</script>
</html>